home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from subprocess import Popen, PIPE
- import calendar
- import datetime
- import logging
- import time
- log = logging.getLogger('util.primitives.misc')
-
- def clamp(number, min_ = None, max_ = None):
- if None not in (min_, max_) and min_ > max_:
- max_ = min_
-
- if min_ is not None:
- number = max(min_, number)
-
- if max_ is not None:
- number = min(max_, number)
-
- return number
-
-
- def backtick(cmd, check_retcode = True):
- proc = Popen(cmd.split(' '), stdout = PIPE)
- proc.wait()
- if check_retcode and proc.returncode != 0:
- raise Exception('subprocess returned nonzero: %s' % cmd)
-
- return proc.stdout.read()
-
-
- class ysha(object):
- h0 = 1732584193
- h1 = 0xEFCDAB89L
- h2 = 0x98BADCFEL
- h3 = 271733878
- h4 = 0xC3D2E1F0L
-
-
- def fromutc(t):
- return datetime.datetime(*time.localtime(calendar.timegm(t.timetuple()))[:-2])
-
-
- def toutc(t):
- return datetime.datetime(*time.gmtime(time.mktime(t.timetuple()))[:-2])
-
-